<template>
  <div class="wholesale-list block">
    <div class="header">
      <h2 class="title">订单类型配置</h2>
      <el-form
        ref="queryForm"
        :inline="true"
        label-position="right"
        :model="tableQuery"
      >
        <el-form-item label="原厂" prop="supplierName">
          <el-select
            v-model="tableQuery.supplierCode"
            filterable
            remote
            clearable
            placeholder="请输入关键词"
            :remote-method="queryOriginalFactoryList"
            :loading="loading"
          >
            <el-option
              v-for="item in originalFactoryList"
              :key="item.originalFactoryCode"
              :label="item.originalFactoryName"
              :value="item.originalFactoryCode"
            />
          </el-select>
        </el-form-item>

        <el-form-item class="form-button">
          <el-button type="primary" @click="queryFormQuery">查询</el-button>
          <el-button @click="queryFormReset">重置</el-button>
        </el-form-item>
        <div class="clear"></div>
      </el-form>
    </div>
    <section class="el-container container-box is-vertical">
      <div class="operate">
        <el-button type="primary" size="mini" @click="onAdd">添加</el-button>
      </div>
      <el-editable
        ref="tableRef"
        v-loading="tableLoading"
        row-key="orderId"
        :data="payload.content"
        height="400"
        stripe
        :columns="listColumns"
        :payload="payload"
        :need-pagination="true"
        @reload="reloadProductData"
      >
        <template slot="default-operation" slot-scope="scope">
          <el-button
            size="small"
            type="text text-primary"
            @click.stop="onEdit(scope.row)"
            >编辑</el-button
          >
          <el-button
            size="small"
            type="text text-primary"
            @click.stop="onDelete(scope.row)"
            >删除</el-button
          >
        </template>
      </el-editable>
    </section>
    <el-dialog
      top="10vh"
      width="500px"
      :title="(editOrderTypeId ? '编辑' : '添加') + '订单类型'"
      :show-close="true"
      :append-to-body="false"
      :visible.sync="dialogVisible"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      @before-close="closeDialog"
    >
      <add-form
        ref="addFormRef"
        :supplier-code="editOrderTypeId"
        @on-save-success="onSaveSuccess"
      />
      <div slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" @click.stop="onSubmit">{{
          editOrderTypeId ? '修改' : '提交'
        }}</el-button>
        <el-button size="small" @click.stop="closeDialog">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script src="./index.js"></script>

<style lang="less" src="./index.less" scoped></style>
